#ifndef KEYBOARDBUTTON_H
#define KEYBOARDBUTTON_H

#include <QPushButton>
#include <QMouseEvent>
#include <QTimer>

class KeyboardButton : public QPushButton
{
    Q_OBJECT

public:
    explicit KeyboardButton(const QString &text, QWidget *parent = nullptr);
    explicit KeyboardButton(const QString &text, const QString &value, QWidget *parent = nullptr);
    
    // 设置按钮值（可能与显示文本不同）
    void setValue(const QString &value);
    QString getValue() const;
    
    // 设置为特殊功能键
    void setFunctionKey(bool isFunction);
    bool isFunctionKey() const;
    
    // 设置按钮大小类型
    enum SizeType {
        Normal,     // 正常大小
        Large,      // 大尺寸（空格键等）
        ExtraLarge  // 超大尺寸（回车键等）
    };
    void setSizeType(SizeType type);
    SizeType getSizeType() const;

protected:
    void paintEvent(QPaintEvent *event) override;
    void mousePressEvent(QMouseEvent *event) override;
    void mouseReleaseEvent(QMouseEvent *event) override;
    void enterEvent(QEvent *event) override;
    void leaveEvent(QEvent *event) override;
    void resizeEvent(QResizeEvent *event) override;

signals:
    void keyPressed(const QString &value);

private slots:
    void onClicked();
    void onReleaseAnimation();

private:
    void setupStyle();
    void updateButtonStyle();
    void updateFontSize();
    
    QString m_value;
    bool m_isFunction;
    SizeType m_sizeType;
    bool m_isPressed;
    bool m_isHovered;
    QTimer *m_pressTimer;
};

#endif // KEYBOARDBUTTON_H